package com.itfenghuang;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.util.Scanner;

public class A02_插入 {
    public static void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        //1.加载驱动
        Class.forName("com.mysql.jdbc.Driver");
        //2.获取连接
        Connection conn = DriverManager.getConnection
                ("jdbc:mysql://127.0.0.1:3306/aa_chun_day02", "root", "123456");
        //占位符
        String sql="insert into student (sid,sname,sage) values(?,?,?)";
        //获取域编译
        PreparedStatement ppp = conn.prepareStatement(sql);
        // set方法赋值
        ppp.setInt(1,sc.nextInt());
        sc.nextLine();
        ppp.setString(2,sc.nextLine());
        ppp.setInt(3,sc.nextInt());
        int update = ppp.executeUpdate();

    }
}
